<!doctype html>
<html>
    <head>
        <title>安平县企业疫情防控信息大数据</title>
    
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
        <link rel="stylesheet" href="layui.css" media="all">
        <script src="layui.js"></script>
        <script src="jquery.1.12.4.js"></script>
        <link href="qiye.css" rel="stylesheet" />
        
    </head>
    <body>
		<div id="black"></div>
		<div id="error">
            <div class="errorImg"><img src="error.png" width="180" height="140" /></div>
            <div class="errorTitle">失败，请选择人员入组！</div>
            <div class="errorBtn">
                <span onlick="Close()">点击关闭</span>
            </div>
		</div>
        <div class="layui-form layBox">
            <dl class="dl">
                <dt>在职人数：</dt>
                <dd>
                    <input type="text" id="member" name="title" lay-verify="title" autocomplete="off" placeholder="请输入在职人数" class="layui-input" value="">
                </dd>
            </dl>
            <dl class="dl">
                <dt>省外职工人数：</dt>
                <dd>
                    <input type="text" id="waisheng" name="title" lay-verify="title" autocomplete="off" placeholder="请输入省外职工人数，没有填 0" class="layui-input" value="">
                </dd>
            </dl>
            <dl class="dl">
                <dt>企业内住宿人数：</dt>
                <dd>
                    <input type="text" id="home" name="title" lay-verify="title" autocomplete="off" placeholder="请输入住宿人数，没有填 0" class="layui-input">
                </dd>
            </dl>
            <dl class="dl">
                <dt>企业内餐人数：</dt>
                <dd>
                    <input type="text" id="meal" name="title" lay-verify="title" autocomplete="off" placeholder="请输入场内用餐人数，没有填 0" class="layui-input">
                </dd>
            </dl>
            <dl class="dl">
                <dt>员工/职工是否有发热：</dt>
                <dd class="radioBox">
                    <div class="radio ac" _code="0">
                        <i>
                            <img src="http://qiye.city1000.cn/library/images/yuan.png" />
                            <img src="http://qiye.city1000.cn/library/images/yuan_ac.png" />
                        </i>
                        <div>否</div>
                    </div>
                    <div class="radio" _code="1">
                        <i>
                            <img src="http://qiye.city1000.cn/library/images/yuan.png" />
                            <img src="http://qiye.city1000.cn/library/images/yuan_ac.png" />
                        </i>
                        <div>是</div>
                    </div>
                </dd>
            </dl>
            <dl class="dl">
                <dt>员工/职工是否有到疫情中高风险地区：</dt>
                <dd class="radioBox_2">
                    <div class="radio ac" _code="0">
                        <i>
                            <img src="http://qiye.city1000.cn/library/images/yuan.png" />
                            <img src="http://qiye.city1000.cn/library/images/yuan_ac.png" />
                        </i>
                        <div>无</div>
                    </div>
                    <div class="radio" _code="1">
                        <i>
                            <img src="http://qiye.city1000.cn/library/images/yuan.png" />
                            <img src="http://qiye.city1000.cn/library/images/yuan_ac.png" />
                        </i>
                        <div>中风险</div>
                    </div>
                    <div class="radio" _code="2">
                        <i>
                            <img src="http://qiye.city1000.cn/library/images/yuan.png" />
                            <img src="http://qiye.city1000.cn/library/images/yuan_ac.png" />
                        </i>
                        <div>高风险</div>
                    </div>
                </dd>
            </dl>
            
            <div class="layui-btn onButton" id="daka" _key="0">打卡</div>
        </div>
        <div class="copy">
            <p><img src="http://qiye.city1000.cn/library/images/tishi.png" width="300" /></p>
            <p style="font-size: 18px;">安平县工业和信息化局</p>
            <p>技术支持：智慧安平</p>
        </div>

        
        <script>
            layui.use(['layer'], function(){
                var layer = layui.layer, //弹层
                form = layui.form;
            });
            /*函数 start*/
            // 获取URL里的参数函数
            function getQueryString(name){
                var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if(r!=null)return  unescape(r[2]); return null;
            }
            var state = getQueryString('state');
            $("#daka").html(state+" 打卡")
            function Tanchuang (str, btnStr, num) {
                var black = $("#black");
                var box = $("#error");
                $(".errorTitle").html(str);
                if(num == 1){
                    // 关闭窗口
                    $(".errorBtn").html("<div class='baifenbai closeError'>"+btnStr+"</div>");
                    $(".closeError").click(function(){
                        var black = $("#black");
                        var box = $("#error");
                        black.fadeOut(500);
                        box.fadeOut(500);
                    });
                }
                if(num == 2){
                    // 跳转链接
                    $(".errorBtn").html("<div class='baifenbai linkUrl'>"+btnStr+"</div>");
                    $(".linkUrl").click(function(){
                        $(location).attr('href', 'http://qiye.city1000.cn/api/content');
                    });
                }
                if(num == 3){
                    // 跳转链接
                    $(".errorBtn").html("<div class='baifenbai linkUrl'>"+btnStr+"</div>");
                    $(".linkUrl").click(function(){
                        $(location).attr('href', 'http://qiye.city1000.cn/api/reg');
                    });
                }
                if(num == 4){
                    // 跳转链接
                    $(".errorBtn").html("<div class='baifenbai linkUrl'>"+btnStr+"</div>");
                    $(".linkUrl").click(function(){
                        $(location).attr('href', 'http://qiye.city1000.cn');
                    });
                }
                
                black.fadeIn(500);
                box.fadeIn(500);
            }
            /*函数 end*/
            var code = getQueryString("code");
           
            if(code == "" || code == undefined || code == null){
                Tanchuang('网络繁忙', '点击重试', 2)
            }
        
            $.ajaxSetup({
                headers:{'X-CSRF-TOKEN':'{{ csrf_token() }}'}
            });
        
            var url = "http://qiye.city1000.cn";
        
            var hot = 0;
            var city = 0;
        
            var radioBox = $(".radioBox");
            var radio = radioBox.find(".radio");
            radio.click(function(){
                hot = $(this).attr("_code");
                $(this).addClass("ac").siblings().removeClass("ac");
            })
        
            var radioBox_2 = $(".radioBox_2");
            var radio2 = radioBox_2.find(".radio");
            radio2.click(function(){
                city = $(this).attr("_code");
                $(this).addClass("ac").siblings().removeClass("ac");
            })
        
            var btn = $(".onButton");
            btn.click(function(){
                var ts = $(this);
                var member = $("#member").val();
                var waisheng = $("#waisheng").val();
                var home = $("#home").val();
                var meal = $("#meal").val();
        
                var reg=/^[0-9]*$/;
                if(!reg.test(member) || member.trim()==""){
                    ts.attr("_key", 0)
                    layer.msg("请输入在职人数，需为正整数", {icon: 2})
                    return false;
                }else if(!reg.test(waisheng) || waisheng.trim()==""){
                    ts.attr("_key", 0)
                    layer.msg("请输入省外职工人数，需为正整数", {icon: 2})
                    return false;
                }else if(!reg.test(home) || home.trim()==""){
                    ts.attr("_key", 0)
                    layer.msg("请输入场内住宿人数，需为正整数", {icon: 2})
                    return false;
                }else if(!reg.test(meal) || meal.trim()==""){
                    ts.attr("_key", 0)
                    layer.msg("请输入场内用餐人数，需为正整数", {icon: 2})
                    return false;
                }
                var key = ts.attr("_key");
                if(key == 0){
                    ts.attr("_key", 1)
                    $.ajax({
                        url: url+"/api/content/create",
                        type: "POST",
                        data:{
                            "member": member,
                            "waisheng": waisheng,
                            "home": home,
                            "meal": meal,
                            "hot": hot,
                            "city": city,
                            "code": code
                        },
                        dataType: "json",	//数据格式，如果后台输出为非json，则会报错，可不填
                        success: function(data){
                            if(data.code == 200){
                                layer.msg(data.msg);
                                setTimeout(function(){
                                    $(location).attr('href', "http://hesuan.city1000.cn/qiye/home.html");
                                }, 1500);
                            }else if(data.code == 405){
                                Tanchuang(data.msg, '点击前往登记', 3)
                            }else if(data.code == 406){
                                Tanchuang(data.msg, '返回首页', 4)
                            }else{
                                layer.msg(data.msg);
                                ts.attr("_key", 0)
                            }
                        },
                        error:function(XMLHttpRequest,textStatus,errorThrown){
                            ts.attr("_key", 0)
                            if(XMLHttpRequest.status!=200){
                                //状态码不为200，均为出错
                            };
                        }
                    });
                }
                
        
            })
        </script>
    </body>
</html>